package com.iyundao.io.mapper;

import com.iyundao.io.model.ActivityModelLookBack;
import com.iyundao.io.tools.ActivityModelVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ActivityModelLookBackCustomMapper {

    @Update("update activitymodellookback set activitytitle=#{activitytitle,jdbcType=VARCHAR}, activitycontent=#{activitycontent,jdbcType=VARCHAR}, activitystarttime=#{activitystarttime,jdbcType=TIMESTAMP}, " +
            "activityendtime=#{activityendtime,jdbcType=TIMESTAMP}, activitysignstarttime=#{activitysignstarttime,jdbcType=TIMESTAMP}, activitysignendtime=#{activitysignendtime,jdbcType=TIMESTAMP}, activitylongitude=#{activitylongitude,jdbcType=DOUBLE}, " +
            "activitylatitude=#{activitylatitude,jdbcType=DOUBLE}, activitysitename=#{activitysitename,jdbcType=VARCHAR}, activitycreatetime=#{activitycreatetime,jdbcType=TIMESTAMP}, activitynumber= #{activitynumber,jdbcType=INTEGER}, " +
            "activityjoinnumber=#{activityjoinnumber,jdbcType=INTEGER}, activityintegral=#{activityintegral,jdbcType=INTEGER}, activityimg=#{activityimg,jdbcType=VARCHAR}, userid=#{userid,jdbcType=VARCHAR}, " +
            "activityflag=0, activityid=#{activityid,jdbcType=INTEGER},activitydigest=#{activitydigest,jdbcType=VARCHAR}, organizationid=#{organizationid,jdbcType=VARCHAR} " +
            "where id = #{id,jdbcType=INTEGER}")
    int update(ActivityModelLookBack activityModel);

    @Select("select a.id, a.activitytitle,a.activitycontent,DATE_FORMAT(a.activitystarttime,'%Y-%m-%d %H:%i:%s') activitystarttime,DATE_FORMAT(a.activityendtime,'%Y-%m-%d %H:%i:%s') activityendtime, " +
            " DATE_FORMAT(a.activitysignstarttime,'%Y-%m-%d %H:%i:%s') activitysignstarttime, DATE_FORMAT(a.activitysignendtime,'%Y-%m-%d %H:%i:%s') activitysignendtime, a.activitylongitude, a.activitylatitude, " +
            " a.activitysitename, DATE_FORMAT(a.activitycreatetime,'%Y-%m-%d %H:%i:%s') activitycreatetime, a.activitynumber, a.activityjoinnumber, a.activityintegral, " +
            " a.activityimg, a.userid, a.activityflag, a.activityid, a.activitydigest, a.organizationid,ac.categoryname,ac.categoryintegral,sd.real_name " +
            "  from activitymodellookback a " +
            " INNER JOIN activitycategory ac " +
            "  on a.activityid= ac.id " +
            " INNER JOIN sys_dept sd " +
            " on a.organizationid=sd.sid " +
            " where a.id=#{id,jdbcType=INTEGER} " +
            "ORDER BY a.id DESC")
    ActivityModelVo selectLookBackById(Integer id);

    @Delete("delete from activitymodellookback where id=#{id,jdbcType=INTEGER}")
    int deleteActivityModelLookBack(Integer id);
}
